package com.xiaotu.mapper;

import com.xiaotu.model.RoomPlayerCoordinateModel;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.BaseMapper;

/**
 * @author 张晓
 * @create 2021-10-18 21:58
 */
@Mapper
public interface CoordinateMapper extends BaseMapper<RoomPlayerCoordinateModel> {

    @Select("<script>" +
            " SELECT " +
            " MAX( step ) step  " +
            "FROM " +
            " tab_room_player_coordinate  " +
            "WHERE " +
            " player_id = #{selfPlayerId}  " +
            " AND room_id = #{roomId} " +
            "</script>")
    Integer getMaxStep(@Param("selfPlayerId") Integer selfPlayerId, @Param("roomId") Integer roomId);

    @Delete("<script>" +
            " DELETE FROM tab_room_player_coordinate WHERE room_id = #{roomId} " +
            "</script>")
    void clearHistoryCoordinate(Integer roomId);
}
